/**
 * 归档历史查询
 */
var vm = new Vue({
    el: "#main",
    data: {
        listArry: [],
        id: "",
        businessNo: "",  // 业务号
        stateValue: "",  // 
        appliName: "",  // 投保人姓名
        nowPage:1,
        rowNum:10,
        allPages:0,
        pagination: [],
        applyCondition:'',//申请条件
        organCode:'',//结构代码
        jsonStr:'',//json串
        tipMsg: '', // 弹出框提示信息
        pageNum:'',  // 跳转页码
    },
    created: function() {
        // this.queryUser();
    },
    methods: {
         
         //分页
         selectPage(page){
            this.nowPage = page;
            this.queryUser();
        },
        offsetPage(offset){
            this.nowPage = this.nowPage + offset;
            this.queryUser();
        },
        queryUser() {
            if(!this.appliName && !this.businessNo && !this.organCode && !this.jsonStr) {
                this.tipMsg = '查询条件不能为空'
                $('#my-alert1').modal({
                    relatedTarget: this,
                });
                this.listArry = []
                return false
            }
            let obj = {
                appliName: this.appliName,
                businessNo: this.businessNo, //业务识别号（保单号）
                nowPage:this.nowPage,
                rowNum:this.rowNum,
                organCode:this.organCode,
                projson:this.jsonStr,
                archiveFlag: '1' // 归档标识，只查询已归档，所以传1
            };
            axios({
                    method: "post",
                    // url: 'http://192.168.1.81:8080/slxt-web/archive/queryArchiveList',  // 文华本地
                    url: App.envUrl.backtrackUrl+"archive/queryArchiveList",
                    data: obj,
                })
                .then((data) => {
                    console.log(data.data.pageCount.datas);
                    var list = data.data.pageCount.datas;
                    // this.nowPage = data.data.pageCount.nowPage;
                    if(list.length > 0){
                        this.allPages = data.data.pageCount.allPages;
                        this.pagination = getPagination(this.nowPage,this.allPages);
                        list.forEach((element) => {
                            element.stateValue = "";
                            if (element.auditState == 0) {
                                element.stateValue = "未审核";
                            } else if (element.auditState == 1) {
                                element.stateValue = "通过";
                            } else if (element.auditState == 2) {
                                element.stateValue = "拒绝";
                            } else if (element.auditState == 3) {
                                element.stateValue = "审核中";
                            }
                        });
                        this.listArry = list;
                    }else if(list.length == 0) {
                        this.tipMsg = '抱歉，未查询到符合条件的数据！'
                        $('#my-alert1').modal({
                            relatedTarget: this,
                        });
                        this.listArry = []
                        this.appliName = ''
                        this.businessNo = ''
                        this.organCode = ''
                        this.jsonStr = ''
                    }
                })
                .catch((err) => {});
        },
        resetBtn() {
            // const this = this;
            this.businessNo = "";
            this.appliName = "";
            this.listArry = []
        },
        checkdis(id, businessNo) {
            window.location.href =
                "dispute.html?id=" + id + "&businessNo=" +(businessNo || '');
        },
        checkModio(id, businessNo) {
            window.location.href =
                "../track/newReplay.html?id=" + id + "&businessNo=" + (businessNo || '');
        },
        // 申请按钮
        applyModio(id) {
            $('#my-alert').modal({
                relatedTarget: this,
            });
            this.id = id;
        },
        // 申请弹框的确定按钮
        confirmBtn(){
            axios({
                method: "post",
                url: App.envUrl.backtrackUrl+"approval/updateApplyInfo",
                // url: 'http://192.168.1.81:8080/slxt-web/approval/updateApplyInfo',  // 文华本地
                data: {
                    collectId: this.id,
                    reqDetail: this.applyCondition,
                    appType: '1'  // 申请类型  回溯申请--0  调档申请--1
                },
                // 申请调阅信息接口
            }).then((data) => {
                console.log(data,'申请条件反参')
            }).catch((err) => {})
        },        
        //业务信息按钮
        businessMsg(){
            window.location.href = "../track/newReplayDetail.html?id=" + id + "&businessNo=" + (businessNo || '');
        },
    },
});

function rowNumChange(value) {
    vm.queryData.rowNum = value;
    vm.queryData.nowPage = 1;
    vm.queryUser();
}